package muse.schedule;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;

public class Task {
	private static HashMap<Integer, Task> tasks;
	public static String[] categories;
	private static int nextID;
	static {
		nextID = 0;
		tasks = new HashMap<Integer, Task>();
		categories = new String[] {
			"Academics",
			"Business",
			"Humanity",
			"Health",
			"Job",
			"Music",
			"Sports"
		};
	}
	public static int addTask(Task t) {
		tasks.put(nextID, t);
		nextID++;
		return nextID;
	}
	
	public static Task getTask(int id) {
		return tasks.get(id);
	}
	
	public static int getIdCap() {
		return nextID;
	}
	private Task parent;
	private TaskData data;
	private Schedule when;
	private boolean active;
	public Task(TaskData which) {
		data = which;
		active = false;
		parent = null;
		when = new Schedule(Frequency.WEEKDAYS, (Calendar)Calendar.getInstance().clone());
	}
	public Task(TaskData which, Task parent) {
		this(which);
		this.parent = parent;
	}
	public void setSchedule(Schedule when) {
		this.when = when;
	}
	public Schedule getSchedule() {
		return when;
	}
	public String getData(String name) {
		if(data.getParams().containsKey(name))
			return data.getParams().get(name);
		return null;
	}
	public void toggle() {
		active = !active;
	}
	public boolean isEnabled() {
		return active;
	}
	public boolean equals(Object o) {
		return o instanceof Task && ((Task)o).getData("name").equals(getData("name"));
	}
	public void setParam(String id, String s) {
		data.getParams().put(id, s);
	}
}
